﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Tasks;

namespace PNut_Project_Lin
{
    public partial class Insurance : PhoneApplicationPage
    {

        List<checkCar> listInsurance = new List<checkCar>();

        public Insurance()
        {
            InitializeComponent();

            this.Loaded += new RoutedEventHandler(Insurance_Loaded);
        }

        void Insurance_Loaded(object sender, RoutedEventArgs e)
        {
            //throw new NotImplementedException();
            stbt.Visibility = System.Windows.Visibility.Collapsed;

            listInsurance.Add(new checkCar("วิริยะประกันภัย", "1557", "picture/viriya1.jpg", "http://www.viriyah.co.th/customer/customer_branch.asp"));
            listInsurance.Add(new checkCar("กรุงเทพประกันภัย", "1620", "picture/bkk.jpg", "http://www.bangkokinsurance.com/home/garage.asp?key=62&region_code=MD"));
            listInsurance.Add(new checkCar("เอเซียประกันภัย", "022549977", "picture/asia.jpg", "http://58.137.173.12/web/service/bangkok.php"));
            listInsurance.Add(new checkCar("MSIG ประกันภัย", "027888000", "picture/msig.jpg", "http://www.msig-thai.com/msig/html/article.aspx?contentid=77"));
            listInsurance.Add(new checkCar("เจ้าพระยาประกันภัย", "026486666", "picture/jaopraya1.jpg", "http://www.allianzcp.com/claims_map_3.jsp"));
            listInsurance.Add(new checkCar("อลิอันซ์ ซี.พี.ประกันภัย", "026389333", "picture/allianz.jpg", "http://www.allianzcp.com/claims_map_3.jsp"));
            listInsurance.Add(new checkCar("อาคเนย์ประกันภัย", "022677777", "picture/Rkanay.jpg", "http://www.seic.co.th/services_search_garage.php"));
            listInsurance.Add(new checkCar("ประกันคุ้มภัย", "022570202", "picture/prakunkum.png", "http://www.safety.co.th/web/web.nsf/New%20Web%20Claim?OpenFrameSet&Frame=main&Src=0/141BFACB769AA2454725707D000D714C"));
            listInsurance.Add(new checkCar("สินมั่นคงประกันภัย", "1596", "picture/sinmunkong.png", "http://inet1.smk.co.th/internet/th/dealers.asp"));
            listInsurance.Add(new checkCar("ประกันภัยไทยวิวัฒน์", "026950800", "picture/thaiwiwat.png", "http://www.thaivivat.co.th/services.php"));
            listInsurance.Add(new checkCar("ประกันภัยศรีเมือง", "026868888", "picture/srimuang.png", "https://www.tokiomarine.co.th/2010/index.htm"));
            listInsurance.Add(new checkCar("อินทรประกันภัย", "022479261", "picture/inton.png", "http://www.indara.co.th/searchdata.aspx"));
            listInsurance.Add(new checkCar("บางกอกสหประกันภัย", "022331998", "picture/bkksa.png", "http://www.bui.co.th/mainpages/index.php"));
            listInsurance.Add(new checkCar("นำสินประกันภัย", "029114488", "picture/numsin.png", "http://www.namsengins.co.th/index.php"));
            listInsurance.Add(new checkCar("ไทยศรีประกันภัย", "028787000", "picture/thaisri1.png", "http://www.thai.insurancethailand.info/insurance-company/Thaisri-Insurance.html"));
            listInsurance.Add(new checkCar("มิตรแท้ประกันภัย", "026407777", "picture/mittha.png", "http://www.mittare.com/index.php?q=node/25"));
            listInsurance.Add(new checkCar("ไทยพาณิชย์สามัคคีประกันภัย", "026404500", "picture/scb.png", "http://www.scsmg.co.th/th/scsmg-networks-service-point.php"));
            listInsurance.Add(new checkCar("เทเวศประกันภัย", "026704444", "picture/tavat.png", "http://www.deves.co.th/Home#"));
            listInsurance.Add(new checkCar("เมืองไทยประกันภัย", "1487", "picture/muangthai1.png", "http://www.muangthaiinsurance.com/"));
            listInsurance.Add(new checkCar("แอกซ่าประกันภัย", "022065488", "picture/axa.png", "http://www.axaagent-worapon.com/index.php/service/axa-hotline-garages-list.html"));
            listInsurance.Add(new checkCar("กรุงไทยพาณิชย์ประกันภัย", "026241111", "picture/kungthai.png", "http://www.kpi.co.th/th/service-networks.php?type=4"));
           
        

            InsuranceListBox.DataContext = listInsurance;

        }

        private void web_bt_Click(object sender, RoutedEventArgs e)
        {
            WebBrowserTask task = new WebBrowserTask();
            task.URL = listInsurance.ElementAt(InsuranceListBox.SelectedIndex).Link;
            task.Show();
        }

        private void tel_bt_Click(object sender, RoutedEventArgs e)
        {
            PhoneCallTask task = new PhoneCallTask();
            task.PhoneNumber = listInsurance.ElementAt(InsuranceListBox.SelectedIndex).Detail;
            task.DisplayName = listInsurance.ElementAt(InsuranceListBox.SelectedIndex).Name;
            task.Show();
        }

        private void InsuranceListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (InsuranceListBox.SelectedIndex != -1)
            {
                stbt.Visibility = System.Windows.Visibility.Visible;
            }
        }
    }
}